package com.example.projecttest.controller;

import com.example.projecttest.poji.PageBean;
import com.example.projecttest.poji.Result;
import com.example.projecttest.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.regex.Pattern;

@Slf4j
@RestController
public class Empcontroller {
    @Autowired
  private EmpService empService;

    @GetMapping("/emps")
    public Result page(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer pageSize, String name, short gender,
                       @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
                       @DateTimeFormat(pattern="yyyy-MM-dd") LocalDate end) {
        log.info("分页查询"+name);
      PageBean pageBean =  empService.page1(page,pageSize,name,gender,begin,end);
        return Result.success(pageBean);
    }
}

